﻿
namespace PoemGame.Domain.Seedwork
{
    public class AggregateRoot:EntityBase,IAggregateRoot
    {
        /// <summary>
        /// 保存内部事件的列表
        /// </summary>
        private readonly List<EventRecordLocal> _localEvents = new List<EventRecordLocal>();
        /// <summary>
        /// 保存外部事件的列表
        /// </summary>
        private readonly List<EventRecordOutBound> _outBoundEvents = new List<EventRecordOutBound>();

        /// <summary>
        /// 获取内部事件列表
        /// </summary>
        /// <returns></returns>
        public IReadOnlyList<EventRecordLocal> GetLocalDomainEvents()
        { return _localEvents; }
        /// <summary>
        /// 获取外部事件列表
        /// </summary>
        /// <returns></returns>
        public IReadOnlyList<EventRecordOutBound> GetOutBoundDomainEvents()
        { return _outBoundEvents; }

        /// <summary>
        /// 清除内部事件
        /// </summary>
        public void ClearLocalDomainEvents()
        {
            _localEvents.Clear();
        }
        /// <summary>
        /// 清除外部事件
        /// </summary>
        public void ClearOutBoundDomainEvents()
        {
            _outBoundEvents.Clear();
        }
        /// <summary>
        /// 增加内部事件
        /// </summary>
        /// <param name="record"></param>
        public void AddLocalEvent(EventRecordLocal record)
        {
            _localEvents.Add(record);
        }
        /// <summary>
        /// 增加外部事件
        /// </summary>
        /// <param name="record"></param>
        public void AddOutBoundEvent(EventRecordOutBound record)
        {
            _outBoundEvents.Add(record);
        }
    }
}
